/**
  ******************************************************************************
  * @author     Chris
  * @since      2024/6/13 13:51
  *
  * @file       pd_timer_etr.h
  * @brief      Header file of TimerETR peripheral driver.
  *
  * @note       This file contains the TimerETR object declaration.
  *
  * @warning    None.
  ******************************************************************************
  * Change Logs:
  *   Date          Author       Notes
  *   2024/6/13     Chris        the first version
  *
  ******************************************************************************
  */

#ifndef JLC_SKY_TIMER_ETR_H
#define JLC_SKY_TIMER_ETR_H

#include "pd_timer.h"
#include "pd_timer_ch.h"

struct TimerETRVtbl;

/** @defgroup Object properties
  * @{
  */
typedef struct {
    Timer *timer;           /* Timer Base Unit              */
    TimerCh *timerCh;       /* Timer channel                */

    uint32_t ETRPolarity;   /* External Trigger Polarity    */
    uint32_t ETRPrescaler;  /* External Trigger Pre-scaler  */
    uint32_t ETRFilter;     /* External Trigger Filter      */

    uint32_t ClockSource;

    // TimerETR virtual table
    struct TimerETRVtbl *vptr;
} TimerETR;
/**
 * @}
 */

/** @defgroup Object virtual table definition
  * @{
  */
struct TimerETRVtbl {
    void (*init)(const TimerETR *this, IRQn_Type irQnType, uint32_t PreemptPriority, uint32_t SubPriority);
};
/**
 * @}
 */

/** @defgroup Object constructor and member function declaration
  * @{
  */
void TimerETR_constructor(TimerETR *this, Timer *timer, TimerCh *timerChannel);
/**
 * @}
 */

/** @defgroup Object virtual table function implementation
  * @{
  */
static inline void TimerETR_init(const TimerETR *this,
                                 IRQn_Type irQnType, uint32_t PreemptPriority, uint32_t SubPriority) {
    this->vptr->init(this, irQnType, PreemptPriority, SubPriority);
}
/**
 * @}
 */


#endif //JLC_SKY_TIMER_ETR_H
